﻿@model IEnumerable<CmsSite>
           
@{
    Layout = "~/admin/Templates/TelerikAdministration.cshtml";
    ViewBag.Title = "Sites";
}

<h1 class="g-clear">
	<i class="b-icon b-icon_h b-icon_h_config"></i>
	<span class="b-overflow">
		Sites management
		<span class="b-intro-text">The following table shows all sites.</span> 
	</span>  
</h1>

<div id="TabStrip" class="t-widget t-tabstrip t-header">
	@Html.Partial("ConfigurationMenu", 1)
	<div style="display: block;" id="TabStrip-1" class="t-content t-state-active">
		<div class="t-content-inner g-clear">
			<p class="clear-left">
			    <a class="b-button" href="@Url.Action("add", "cmssite")">Create a new site</a>
			    <a class="b-button" href="@Url.Action("clone", "cmssite")">Clone a site</a>
			</p>
			@{Html.RenderPartial("ErrorPanel");}
			@(Html.Telerik().Grid(Model).Name("SiteGrid")
			        .Columns(columns =>
			        {
                        columns.Bound(p => p.SiteName)
                            .Template(@<text><a href="@Url.Action("edit", "cmssite", new {id=item.Id})">@item.SiteName</a></text>)
                            .ClientTemplate("<a href='" + @Url.Action("edit", "cmssite") + "/<#=Id#>'><#=SiteName#></a>");
                        columns.Bound(p => p.SiteGroup.SiteGroupName);                        
			            columns.Bound(p => p.DateCreated).Format("{0:dd/MM/yyyy}").ClientTemplate("<#= $.telerik.formatString('{0:dd/MM/yyyy}', DateCreated) #>");
			            columns.Bound(p => p.Id);
			            columns
                            .Template(@<text><a title="Export" href="@Url.Action("export", "cmssite", new { id = item.Id })">Export</a></text>)
                            .ClientTemplate("<a title='Export' href='"+@Url.Action("export", "cmssite")+"/<#=Id#>'>Export</a>")
			                .Title("Export");
			
			        })
			                                .DataBinding(dataBinding =>
			                                {
			                                    dataBinding.Ajax().Select("_index", "cmssite");
			                                })
			                                .Scrollable(scrolling => scrolling.Enabled(false))
			                                .Sortable(sorting => sorting.Enabled(true))
			                                .Pageable(paging => paging.Style(GridPagerStyles.Numeric).Total(ViewBag.Total).PageSize(ViewBag.PageSize).Enabled(ViewBag.Total > ViewBag.PageSize))
			                        )
			@{Html.RenderPartial("GridSizer", (int)ViewBag.PageSize);}
		</div>
	</div>
</div>